package com.wenx.v3system.modular.cloud.domain.dto;

import com.wenx.base.domain.BaseDto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

/**
 * 系统权限条件DTO
 * 
 * @author wenx
 * @since 1.0.0
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Schema(description = "系统权限条件信息")
public class SysPermissionConditionDto extends BaseDto {

    @NotNull(message = "权限ID不能为空")
    @Schema(description = "权限ID", example = "1001")
    private Long permissionId;

    @NotBlank(message = "条件字段不能为空")
    @Size(max = 100, message = "条件字段长度不能超过100个字符")
    @Schema(description = "条件字段", example = "department")
    private String field;

    @NotBlank(message = "操作符不能为空")
    @Schema(description = "操作符：=, !=, in, not_in, >, <, >=, <=, contains, like", example = "=")
    private String operator;

    @Schema(description = "条件值", example = "admin")
    private String value;

    @Schema(description = "从上下文获取值的字段名", example = "user.departmentId")
    private String contextField;

    @Size(max = 500, message = "条件描述长度不能超过500个字符")
    @Schema(description = "条件描述", example = "只能操作本部门数据")
    private String description;

    @NotBlank(message = "条件类型不能为空")
    @Schema(description = "条件类型：user-用户条件, resource-资源条件, environment-环境条件", example = "user")
    private String type;

    @Schema(description = "条件状态：1-启用，0-禁用", example = "1")
    private Integer status;

    @Schema(description = "排序", example = "1")
    private Long sort;

    // 关联信息
    @Schema(description = "权限名称")
    private String permissionName;

    @Schema(description = "权限编码")
    private String permissionCode;
    
    @Schema(description = "关联的数据库表名", example = "sys_user")
    private String tableName;
    
    @Schema(description = "完整SQL表达式，支持复杂权限逻辑")
    private String sqlExpression;
    
    @Schema(description = "启用状态：1-启用，0-禁用", example = "1")
    private Integer enabled;
    
    @Schema(description = "优先级，数值越小优先级越高", example = "100")
    private Integer priority;
}